﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DalatCooking.Core;
using DalatCooking.Core.Helper;
public partial class admin_Contact_Add_Edit : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected override void OnInit(EventArgs e)
    {
        BinData();
        DeleteSelectedItem();
        base.OnInit(e);
    }
    void DeleteSelectedItem()
    {
        /*
        List<FileAttachment> list = FileAttachment.FileAttachment_ByContact(DeleteID);
        foreach (var item in list)
        {
            FileAttachment.Delete(item.FileAttachmentID);
            File.Delete(Server.MapPath(item.FileUrl));
        }
         * */
        if (ContactManager.Delete(DeleteID) == true)
        {
            Response.Redirect("Default.aspx");
        }
    }
    public int DeleteID
    {
        get
        {
            if (Request.QueryString["DeleteID"] != null)
                return ConvertObject.ToInt(Server.HtmlEncode(Request.QueryString["DeleteID"]));
            else return -1;
        }
    }
    public Contact ContactDetail
    {
        get
        {
            return ContactManager.Single(ContactID);
        }
    }
    void BinData()
    {
       // rptAttachment.DataSource = FileAttachment.FileAttachment_ByContact(ContactID);
       // rptAttachment.DataBind();
    }
    public int ContactID
    {
        get
        {
            if (!String.IsNullOrEmpty(Request.QueryString["ContactID"]))
            {
                return ConvertObject.ToInt(Request.QueryString["ContactID"]);
            }
            return -1;
        }
    }
}